<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../Template/AdminTemplate.xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <f:view>
            <h:form id="form">
                <p:growl id="msgs" showDetail="true" />
                <p:fieldset legend="Prize Manager">
                    <p:dataTable value="#{prizeControl.allPrize}" var="item"  tableStyle="width:auto" widgetVar="carsTable"   
                                 emptyMessage="No Prize found with given criteria" style="width: 800px">
                    <f:facet name="header">  
                     
                    <p:outputPanel>  
                        <h:outputText value="Search all fields:" />  
                        <p:inputText id="globalFilter" onkeyup="carsTable.filter()" style="width:150px" />  
                    </p:outputPanel>
                    </f:facet>
                        <p:column    
                        headerText="Title" footerText="contains"  
                        filterMatchMode="contains" >  
                        
                        <h:outputText value="#{item.title}"/>
                       
                    </p:column>
                        <p:column    
                            headerText="Prize Date" footerText="contains"  >
                        
                            <h:outputText value="#{item.prizeDate}" >
                        <f:convertDateTime pattern="MM/dd/yyyy " />
                        </h:outputText>
                    </p:column>
                        <p:column  filterBy="#{item.eventId.title.substring(0, 10)}"   
                         footerText="contains"  
                        filterMatchMode="contains">  
                            <h:outputText value="#{item.eventId.title.substring(0, 10)}" />  
                            
                        
                    </p:column>
                    
                    
                    <p:column >  
                        
                        <p:commandButton id="selectButton" update=":form:display" oncomplete="carDialog.show()" icon="ui-icon-search" title="View">  
                            <f:setPropertyActionListener value="#{item}" target="#{prizeControl.prize}" />  
                        </p:commandButton>  
                    </p:column>
                        <p:column>
                            <p:commandButton style="font-size: 11px;" value="Update" action="#{prizeControl.showDetail(item)}" icon="ui-icon-arrowrefresh-1-w"/>  
                    </p:column> 
                    <p:column>
                                    <p:commandButton style="font-size: 11px;" value="Delete"  onclick="confirmation.show()" icon="ui-icon-close" >
                                        <f:setPropertyActionListener value="#{item}" target="#{prizeControl.prize}" />
                                    </p:commandButton>
                                    <p:confirmDialog id="confirmDialog" message="Are you sure about delete this Event?"  
                                                     header="Initiating destroy process" severity="alert" widgetVar="confirmation">
                                        <p:commandButton id="confirm" style="font-size: 11px;" actionListener="#{prizeControl.delete(item)}" value="Yes Sure" oncomplete="confirmation.hide()"/>
                                        <p:commandButton id="decline" style="font-size: 11px;" value="Not Yet" onclick="confirmation.hide()" />   
                                    </p:confirmDialog>
                    </p:column>
                    
                </p:dataTable>
                </p:fieldset>
                <p:dialog header="Event Detail" widgetVar="carDialog" resizable="false" id="carDlg"  
                        showEffect="fade" hideEffect="explode" modal="true">  
                    <h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">  
  
                        <f:facet name="header">  
                            <h:outputText value="#{prizeControl.prize.eventId.title.substring(0, 10)}"/> 
                        </f:facet>  
  
                        <h:outputText value="Title:" />  
                        <h:outputText value="#{prizeControl.prize.title}" style="font-weight:bold"/>  
  
                        <h:outputText value="Description:" />  
                        <h:outputText value="#{prizeControl.prize.description}" style="font-weight:bold"/> 
                            
  
                        <h:outputText value="DatePrize:" />  
                        <h:outputText value="#{prizeControl.prize.prizeDate}" style="font-weight:bold">  
                            <f:convertDateTime pattern="MM/dd/yyyy " />
                        </h:outputText>
                        
  
                    </h:panelGrid>  
  
                </p:dialog>
            </h:form>
        </f:view>
    </ui:define>

</ui:composition>
